home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15408 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: cdf.toronto.edu!news
  3. From: p a u l <a209dowm>
  4. Subject: help! getting EOF in the middle of the file!
  5. Content-Type: text/plain; charset=us-ascii
  6. Message-ID: <DpDL8o.6xs@cdf.toronto.edu>
  7. Sender: news@cdf.toronto.edu (Usenet News)
  8. Nntp-Posting-Host: tonnyx
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Computing Disciplines Facility, University of Toronto
  11. Mime-Version: 1.0
  12. Date: Fri, 5 Apr 1996 06:12:22 GMT
  13. X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.3 sun4c)
  14. X-Url: news:comp.lang.c++
  15.  
  16. I have a program that was working fine using cin, and I tried to change it so
  17. it reads from a file.
  18.  
  19. It was working with the exact same data file before when I used:
  20. a.out < datafile
  21.  
  22. now it doesn't work, see the code below:
  23.  
  24. int x;
  25. ifstream in_stream;
  26.  
  27. // in_stream is open and I'm reading from it no problem. 
  28. // I'm halfway through the input file, and in_stream.eof() == 0 right now
  29.  
  30. x = in_stream.get();
  31.  
  32. // now in_stream.eof() == 1
  33. // but I haven't reached the end of the file!!
  34.  
  35. What could be going wrong here?  Any suggestions would be greatly appreciated.
  36.  
  37. Thanks,
  38. Paul.
  39.  
  40.